angular.module('furion.controllers.main', [])

# rootCtrl
.controller 'RootCtrl', ($scope, $rootScope, RemoteSrv, GestureService) ->
  $scope.pullAccountInfo = ()->
    RemoteSrv.getAccountInfo().done (resp)->
      furion.storage.updateAccount(resp.data.account)
    return

  # GestureService.checkLockPattern(false)

  return

.controller 'AppCtrl', ($scope, $state, $ionicViewSwitcher, $ionicTabsDelegate, GestureService, Toast)->
  # tabs 和 '$stateChangeStart' 事件期望不一致，单独判断下

  $scope.onSelectTabAccount = ()->
    if furion.storage.isLogin()
      $ionicTabsDelegate.select(3)
    else
      $scope.$emit("modals:open", {modal_name: 'signin', params: {state: 'app.home'}})

  # $scope.$on '$ionicView.beforeEnter', ()->
  #   if $state.is('app.home') || $state.is('app.invest') || $state.is('app.account') || $state.is('app.more')
  #     $ionicTabsDelegate.showBar(true)
  #   else
  #     $ionicTabsDelegate.showBar(false)

  return